package com.byb.server.service.util;

import com.byb.server.domain.Product;
import com.byb.server.service.dto.Product_sort;

import java.util.List;
import java.util.stream.Collectors;

/**
 * sore rank for product.
 */
public class sortByScore implements SortStrategy {

    /**
     *
     * @param list
     * @param products
     * @param payment
     * @return list of entities
     */
    @Override
    public List<Product_sort> sortBy(List<Product_sort> list, List<Product> products,List<Product> data, Integer payment) {
        return  SortUtil.filterProduct(list, products ,data, payment).stream().sorted((a,b)->b.getOverScore().compareTo(a.getOverScore()))
            .collect(Collectors.toList());
    }
}
